#!/bin/bash
for domain in w18.181
do
sz=`virsh list |grep $domain |grep -c running`
if [[ sz -eq 0 ]];then
IP=192.168.${domain:1}
#guestmount -d $domain -m /dev/sda2 /mnt
guestmount -d $domain -m /dev/mapper/vg-root /mnt
sed -i '/BOOTPROTO/s/dhcp/static/' /mnt/etc/sysconfig/network-scripts/ifcfg-eth0
echo "IPADDR=$IP" >> /mnt/etc/sysconfig/network-scripts/ifcfg-eth0
{
cat <<'XUNLEI'
NETMASK=255.255.255.0
GATEWAY=192.168.18.1
DNS1=119.29.29.29
XUNLEI
} >> /mnt/etc/sysconfig/network-scripts/ifcfg-eth0
#sed -i "s/IPADDR=.*/IPADDR=$IP/" /mnt/etc/sysconfig/network-scripts/ifcfg-eth0
#sed -i "s/GATEWAY=.*/GATEWAY=192.168.18.1/" /mnt/etc/sysconfig/network
umount /mnt
fi
done

